<?php

namespace App\Modules\Medicinal\Services;
use Illuminate\Support\Facades\DB;
use  App\Modules\Medicinal\Models\Medicinal;



class MedicinalService
{

    //设备列表
    public static function getList($params){
        $obj = Medicinal::where('status',1)->orderBy('id','desc');
        if(isset($params['medicinal_name']) && $params['medicinal_name']) {
            $obj->where('medicinal_en','like','%'.$params['medicinal_name'].'%')->orWhere('medicinal_cn','like','%'.$params['medicinal_name'].'%');

        }

        if(isset($params['insulin_type']) && $params['insulin_type']) {
            $obj->where('insulin_type',$params['insulin_type']);

        }

        if(isset($params['insulin_preparation']) && $params['insulin_preparation']) {
            $obj->where('insulin_preparation',$params['insulin_preparation']);

        }
        return $obj->paginate(10);

    }

    public static function upMedicinal($id,$param){

        return Medicinal::where('id',$id)->update($param);

    }




    public static function insertMedicinal($param){
        return Medicinal::create($param);

    }


    public static function oneMedicinal($id){

        return Medicinal::where('id',$id)->first();
    }

    public static function medicinalList(){
        return Medicinal::getList();
    }

}